#include <iostream>
#include <random>
#include <chrono>
#include <string>

// 生成随机字符串
std::string generateRandomString(int length, std::mt19937& rng) {
    std::uniform_int_distribution<int> distribution(0, 35);

    std::string characters = "0123456789abcdefghijklmnopqrstuvwxyz";
    std::string randomString;

    for (int i = 0; i < length; ++i) {
        int index = distribution(rng);
        randomString += characters[index];
    }

    return randomString;
}

int main() {
    int length, seed;

    std::cout << "Enter the length of the random string: ";
    std::cin >> length;

    std::cout << "Enter the seed: ";
    std::cin >> seed;

    std::mt19937 rng(seed);  // 初始化随机数生成器

    std::string randomString;

    while (true) {
        std::cout << "Press Enter to generate a random string (or 'q' to quit): ";
        std::cin.ignore();

        std::string input;
        std::getline(std::cin, input);

        if (input == "q") {
            break;  // 用户输入 'q' 退出循环
        }

        randomString = generateRandomString(length, rng);
        std::cout << "Random string: " << randomString << std::endl;
    }

    return 0;
}
